Skip to content

fix(llmcore): preserve exception chain on empty-response ConnectionError#662

Closed
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/llmcore-b904-raise-from
Closed

fix(llmcore): preserve exception chain on empty-response ConnectionError#662
Kailigithub wants to merge 1 commit into
lsdefine:mainfrom
Kailigithub:fix/llmcore-b904-raise-from

Conversation

@Kailigithub

Copy link
Copy Markdown
Contributor

Summary

The except StopIteration block in _stream (llmcore.py:388) re-raised ConnectionError("empty response") without preserving the original exception chain. Adding from e ensures the traceback shows the full causal chain, which helps diagnose intermittent empty-response issues during LLM streaming.

Changes

  • llmcore.py:388raise requests.ConnectionError("empty response")raise requests.ConnectionError("empty response") from e

One-token change (from e). The ConnectionError is caught by the outer retry handler on line 390, so runtime behavior is unchanged — only the traceback quality improves.

Verification

  • py_compile llmcore.py — passes
  • ruff check llmcore.py --select=B904 — passes (was the only remaining B904 in the file)
  • Exception-chain test: confirms exc.__cause__ is a StopIteration instance after the fix

@Kailigithub

Copy link
Copy Markdown
Contributor Author

Closing this PR — it has been open for 19 days with no review activity. This change falls into the bot's B904 / raise ... from series, which the maintainer has not accepted in this repository (see prior close pattern on #663, #556, #557, #558, #481, #529, #530, and the bot's own close on #663 explicitly noting "The repository has not accepted the bot B904/lint-cleanup series"). The underlying traceback-preservation is a real lint concern, but the maintainer's preferred approach here is clearly narrower / not-via-raise from. Diff preserved at commit 0938e03 and can be cherry-picked if a maintainer requests it. Will defer future B904-style PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant